package com.jiesen.base.modules.company.service.impl;

import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleSelectRestriction;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jiesen.base.modules.login.jsLoginUser.model.JsLoginUser;
import org.springframework.stereotype.Service;

import com.jiesen.base.baseDao.BaseServiceImpl;
import com.jiesen.base.modules.company.mapper.JsPublicUsersMapper;
import com.jiesen.base.modules.company.model.JsPublicUsers;
import com.jiesen.base.modules.company.service.IJsPublicUsersService;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 公海用户 服务实现类
 * </p>
 *
 * @author bao
 */
@Service
public class JsPublicUsersServiceImpl extends BaseServiceImpl<JsPublicUsersMapper, JsPublicUsers>implements IJsPublicUsersService {

    @Transactional(readOnly=false)
    public List<JsPublicUsers> addList(List<JsPublicUsers> arrayList){
        ArrayList<JsPublicUsers> arrayList1 = new ArrayList<JsPublicUsers>();
        for (JsPublicUsers jsPublicUsers : arrayList) {
            try {
                baseMapper.insert(jsPublicUsers);
            } catch (Exception e) {
                arrayList1.add(jsPublicUsers);
            }
        }
        return arrayList1;
    }

    @Override
    public IPage<JsPublicUsers> selectPage(IPage<JsPublicUsers> page, QueryWrapper<JsPublicUsers> queryWrapper) {
        IPage<JsPublicUsers> jsPublicUsersIPage = baseMapper.selectPage(page, queryWrapper);
        return jsPublicUsersIPage;
    }

    @Override
    @Transactional(readOnly=false)
    public synchronized int updateJsPublicUsers(List<Integer> ids, JsPublicUsers jsPublicUsers) {
    	int i=0;
        for (Integer id : ids) {
            if(id.equals(""))
            jsPublicUsers.setId(id);
            i+=baseMapper.updateById(jsPublicUsers);
        }
        return i;
    }

}
